package cn.com.pet.community.action.encyclopedia;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import cn.com.pet.common.base.BaseAction;
import cn.com.pet.common.entity.PetInfo;
import cn.com.pet.common.service.PetInfoService;

@Namespace("/action")
@ParentPackage("base")
@SuppressWarnings("serial")
public class PetInfoIndex extends BaseAction {

	@Autowired
	PetInfoService petInfoService;

	@Action(value = "getPetInfo", results = {
			@Result(name = SUCCESS, location = "/html/community/encyclopedia/petInfoIndex.jsp") })
	public String getPetInfo() {
		String petId = this.getRequest().getParameter("id");

		PetInfo petInfo = new PetInfo();
		petInfo.setPetId(petId);

		List<PetInfo> allPetInfo = petInfoService.getPetInfoByPetId(petInfo);

		this.getRequest().setAttribute("allPetInfo", allPetInfo);
		return SUCCESS;
	}
}
